
class vertice4f {
  float x;
  float y;
  float z;
  float w;
  vertice4f () {x=0;y=0;z=0;w=1;}
  vertice4f (float a,float b,float c) {x=a;y=b;z=c;w=1;}
  void setVertice4f (float a,float b,float c) {x=a;y=b;z=c;w=1;}
};

class polyFaces {
  int numOfV;
  int numOfF;
  vertice4f vertices[];
  int faces[][];
  polyFaces (int numOfVertices,float verticesF[][],int numOfFaces,int facesF[]) {
    int faceBuf[] = new int[30];
    int faceCnt=0,i=0,j=0,k=0;
    numOfV = numOfVertices;
    numOfF = numOfFaces;
    vertices = new vertice4f[numOfV];
    faces = new int[numOfF][];
    for (i=0;i<numOfV;i++) vertices[i] = new vertice4f(verticesF[i][0],verticesF[i][1],verticesF[i][2]);
    j=0;
    for (i=0;i<numOfF;i++) {
      faceCnt=0;
      while ((facesF[j]>=0)&&(facesF[j]<numOfV)) {
        faceBuf[faceCnt++] = facesF[j++];
        println(faceBuf[faceCnt-1]);
      }
      faces[i] = new int[faceCnt];
      for (k=0;k<faceCnt;k++) faces[i][k] = faceBuf[k];
    }
  }
  
};

float Sverts[][] = new float[][]{{0,0,0},{100,100,0},{200,100,0}};
int Sfaces[] = new int[] {0,1,-1,1,2,-1,0,2,-1};
int SnumFace = 3;
int SnumVert = 3;
polyFaces myPoly = new polyFaces(SnumVert,Sverts,SnumFace,Sfaces);

void setup () {
  size(600,600);
  background(0);
  rectMode(CORNERS);
}

void draw() {
  background(0);
  rect(0,0,300,300);
}
